package akshay.drawing;


import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.ViewGroup.LayoutParams;
import android.widget.Toast;

public class SmartDrawingActivity extends Activity {
	static Display v;
	static int count=0;
    /** Called when the activity is first created. */
	 public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        //setContentView(new myView(getBaseContext()));
	        if(count==0){
	        	Toast.makeText(getApplicationContext(), "Click on option menu", Toast.LENGTH_SHORT).show();
	        	count++;
	        }
	        
	        LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
	        v=new Display(getApplicationContext());
	        setContentView(new Display(getBaseContext()), layoutParams);
	      }
	    SubMenu drawMenu;
	    
		  @Override  
		    public boolean onCreateOptionsMenu(Menu menu) {  
		      //menu.add(0,0,0,"Insert");
		      drawMenu = menu.addSubMenu("Draw");
		      
		      drawMenu.add(0,2,0,"Circle");
		       
		        drawMenu.add(0,3,0,"Rectangle");
		       
		  
		      return super.onCreateOptionsMenu(menu);  
		      
		    }
		    public boolean onOptionsItemSelected(MenuItem item) {
		    	  // TODO Auto-generated method stub
		    	  switch(item.getItemId()){
		    	  case 0:
		    	   drawMenu.setGroupVisible(2, true);
		    	   
		    	   break;
		    	  case 2:
		    		  v.setCircle(true);
		      		  v.iscirclenew=true;
		    		  v.invalidate();
		    		  v.setVisibility(0);
		    		  this.setContentView(v);
		    		  
				          break;
		    	  case 3:
		    		  v.setRect(true);
		       	   	  v.invalidate();
		       	 	  v.setVisibility(0);
		       	 	  this.setContentView(v);
		       	 	  break;
		       	  
		    	  }
		    	  return true;
		    }
	  
}